/*
 * User: rant
 * Date: Sep 9, 2007
 *
 *
 */
package laMalinche.testingPlayGround.flow;

import java.util.*;

/**
 *
 */
public class FlowNodeFactory {
	private final Map<Collector, BasicFlowNode> flowNodeMap;
	private static FlowNodeFactory instance;

	private FlowNodeFactory() {
        flowNodeMap = new HashMap<Collector, BasicFlowNode>();
	}

	public static FlowNodeFactory getInstance() {
		if (instance == null) {
			instance = new FlowNodeFactory();
		}
		return instance;
	}

	public BasicFlowNode getFlowNode(final Collector collector) {
		if (flowNodeMap.containsKey(collector)){
			return flowNodeMap.get(collector);
		} else {
			final BasicFlowNode flowNode = new BasicFlowNode(collector);
			flowNodeMap.put(collector,flowNode);
			return flowNode;
		}
	}
}